package com.iwhalecloud.bss.kite.cucc.service.util;

import com.iwhalecloud.bss.kite.common.cache.AbstractCache;
import com.iwhalecloud.bss.kite.common.util.KiteListUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import com.ztesoft.bss.common.util.SpringUtil;

import java.util.List;

public class LocalCacheUtils {

    public static String getAttrValueByAttrIdAndAttrValueCode(String attrId, String attrValueCode) {
        String attrValue = "";
        AbstractCache attrValueCache = SpringUtil.getBean(KiteStringUtils.uncapitalize("AttrValueCache"));
        List<AttrValue> list = attrValueCache.defaultGetObject(attrId);
        if(!KiteListUtils.isEmpty(list)){
            for(AttrValue value : list){
                if(KiteStringUtils.isEqual(value.getAttrValueCode(),attrValueCode)){
                    attrValue = value.getAttrValue();
                }
            }
        }
        return attrValue;
    }

}
